package controller.audio;

import controller.audio.Interface.IAudioController;
import model.audio.AudioCaptureModel;
import model.audio.AudioMixerModel;
import model.audio.AudioTransmissionModel;
import model.audio.Interface.AudioStateObserver;
import model.audio.Interface.DBObserver;
import model.audio.Interface.IAudioCaptureModel;
import model.audio.Interface.IAudioMixerModel;
import model.audio.Interface.IAudioTransmissionModel;
import model.roomManagement.Implementation.RoomManageModel;
import model.roomManagement.Interface.IPObservable;

public class AudioController implements IAudioController{

	private IAudioCaptureModel IACM=null;
	private IAudioTransmissionModel IATM=null;
	private IAudioMixerModel IAMM=null;
	
	public AudioController(AudioStateObserver aso,DBObserver dbo){
		AudioMixerModel AMM=new AudioMixerModel();
		AudioTransmissionModel ATM=new AudioTransmissionModel(AMM, null, AudioCaptureModel.BUFFER_LENGTH);
		AudioCaptureModel ACM=new AudioCaptureModel(ATM);
		//ATM.connect(123111);
		IPObservable ipobservable=RoomManageModel.getInstance();
		ipobservable.addObserver(ATM);
		ACM.addObserver(aso);
		AMM.addObserver(aso);
		ACM.addObserver(dbo);
		this.IACM=ACM;
		this.IATM=ATM;
		this.IAMM=AMM;
	}

	@Override
	public void setMicroVolume(float value) {
		// TODO Auto-generated method stub
		IACM.setMicroVolume(value);
	}

	@Override
	public void setVolume(float value) {
		// TODO Auto-generated method stub
		IAMM.setVolume(value);
	}

	@Override
	public void startAudioSession() {
		// TODO Auto-generated method stub
		IATM.startAudioTransmission();
		IACM.startAudioCapture();
	}

	@Override
	public void stopAudioSession() {
		// TODO Auto-generated method stub
		IAMM.stop();
		IACM.stopAudioCapture();
		IATM.stopAudioTransmission();
	}
	
}
